<?php

use Phalcon\Forms\Element\Email,
    Phalcon\Forms\Element\Text,
    Phalcon\Forms\Element\Hidden,
    Phalcon\Forms\Element\Submit,
    Phalcon\Validation\Validator\PresenceOf,
    Phalcon\Validation\Validator\Email As EmailValidate,
    Phalcon\Validation\Validator\Identical;

/**
 * validate and print render Frontend login form
 */
class RoleForm extends BaseForm {

    public function initialize() {
        
        // Name
        $name = new Text('name', array(
            'placeholder' => 'Full Name',
            'required' => true,
        ));
        $name->addValidators(array(
            new PresenceOf(array(
                'message' => 'Name is required!'
                    ))
        ));
        $this->add($name);

        //CSRF
        $csrf = new Hidden('csrf');
        $csrf->addValidator(
                new Identical(array(
            'value' => $this->security->getSessionToken(),
            'message' => 'CSRF validation failed'
                ))
        );
        $this->add($csrf);
        
        // Submit button
        $this->add(new Submit('submit', array(
            'class' => 'btn btn-primary btn-large'
        )));
    }

}
